import React, {useEffect, useState} from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  ActivityIndicator,
  FlatList,
  Image,
  TextInput,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import AreaView from '../../components/Layout/AreaView';
import CommentInput from '../../components/CommentInput';
import styles from './style';
import {topicDetail} from '../../service/common';
import BaseUrl from '../../config/BaseUrl';

const TopicDetail = (props) => {
  const {
    route: {
      params: {id},
    },
  } = props;

  const navigation = useNavigation();
  const [data, setData] = useState({});

  useEffect(() => {
    topicDetail({id}).then((res) => {
      setData(res.data);
    });
  }, []);
  return (
    <AreaView>
      {/* <View style={styles.topic_container}>
        <View style={styles.head_container}>
          <Image style={styles.avatar} />
          <View style={styles.name_time}>
            <View style={styles.name_time_top}>
              <Text style={styles.name_text}>Lajdjaa</Text>
              <Text style={styles.time_t_text}>2020.11.01 01:01</Text>
            </View>
            <View style={styles.time_bottom}>
              <Text style={styles.time_b_text}>51分钟前</Text>
            </View>
          </View>
        </View>
        <View style={styles.topic_content}>
          <Text style={styles.content_text}>#精选话题# 考试为啥这么难？</Text>
        </View>
        <View style={styles.img_container}>
          <Image style={styles.topic_img} />
        </View>
      </View> */}
      <View style={styles.comment}>
        <View style={styles.comment_list}>
          <View style={styles.head_container}>
            <Image
              style={styles.avatar}
              source={{uri: BaseUrl.imgurl + data?.portrait}}
            />
            <View style={styles.name_time}>
              <View style={styles.name_time_top}>
                <Text style={styles.name_text}>{data?.createdName}</Text>
              </View>
              <View style={styles.time_bottom}>
                <Text style={styles.time_b_text}>{data?.createdTime}</Text>
              </View>
            </View>
          </View>
          <View style={styles.topic_content}>
            <Text style={styles.content_text}>#话题内容# {data?.title}</Text>
          </View>
          <View style={styles.children_commen}>
            <View style={styles.children_head_container}>
              <Image
                style={styles.children_avatar}
                source={{uri: BaseUrl.imgurl + data?.aswUserPortrait}}
              />
              <View style={styles.children_name_time}>
                <View style={styles.children_name_time_top}>
                  <Text style={styles.children_name_text}>
                    {data?.aswUserName}
                  </Text>
                </View>
                <View style={styles.children_time_bottom}>
                  <Text style={styles.children_time_b_text}>
                    {data?.aswTime}
                  </Text>
                </View>
              </View>
            </View>
            <View style={styles.children_topic_content}>
              <Text style={styles.children_content_text}>
                {data?.aswContent}
              </Text>
            </View>
          </View>
        </View>
      </View>
      {/* <CommentInput /> */}
    </AreaView>
  );
};

export default TopicDetail;
